﻿Imports Oracle.DataAccess.Client
Public Class fListaTipoPago
    Private lidPago As String
    Public ReadOnly Property idPago() As String
        Get
            Return lidPago
        End Get
    End Property

    Private Sub btnConsulta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsulta.Click
        Dim Conn As OracleConnection = New OracleConnection(My.Settings.ConnectionString)
        Dim cmd As OracleCommand = Conn.CreateCommand
        If Me.txtDescripPago.Text.Trim.Length = 0 Then
            cmd.CommandText = "SELECT IDTIPOPAGO, DESCRIPCION FROM CAR_TIPOPAGO "
        Else
            cmd.CommandText = "SELECT IDTIPOPAGO, DESCRIPCION FROM CAR_TIPOPAGO DESCRIPCION LIKE '" & Me.txtDescripPago.Text & "'"
        End If
        Try
            Conn.Open()
            DsCartera.CAR_TIPOPAGO.Clear()
            DsCartera.CAR_TIPOPAGO.Load(cmd.ExecuteReader)
            Conn.Close()
            CAR_TIPOPAGODataGridView.Focus()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        End Try
    End Sub

    Private Sub bntCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles bntCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub CAR_TIPOPAGODataGridView_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles CAR_TIPOPAGODataGridView.CellMouseDoubleClick
        If e.RowIndex >= 0 Then
            lidPago = CAR_TIPOPAGODataGridView.Rows(e.RowIndex).Cells("IDTIPOPAGO").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub


    Private Sub AsignaTipoPago(ByVal Fila As Integer)
        If Fila >= 0 Then
            lidPago = CAR_TIPOPAGODataGridView.Rows(Fila).Cells("IDTIPOPAGO").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub CAR_TIPOPAGODataGridView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles CAR_TIPOPAGODataGridView.KeyDown
        If e.KeyData = Keys.Enter Then
            AsignaTipoPago(CAR_TIPOPAGODataGridView.CurrentRow.Index)
        End If
    End Sub
End Class